

from abc import ABC, abstractmethod
from pojo.BaseLogin import BLogin


class AModelData(ABC):

    BLogin = None
    def setBlogin(self,BLogin):
        self.BLogin = BLogin
        # 获取模式数据,这里直接调用,初始化的时候完成模式数据的获取
        self.getModelData()
    # 下注金额每一项
    full_data = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 63, 69, 73, 75, 75, 73, 69, 63, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1]
    # 基数列表
    temp_list = []
    # @property
    # def getFullData(self):
    #     return self.full_data

    # 模式和, 比如500  666  888
    modelSum =""
    @abstractmethod
    def getModelData(self):
        pass


    """
        2N,3N,4N,5N时使用
    """
    def getModelSum(self,firstNum,secondNum,thirdNum=None):
        self.full_data = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 63, 69, 73, 75, 75, 73, 69, 63, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1]
        if BLogin is None:
            print("模式设置 - BLogin is None,请检查")
            return
        self.modelSum = 0
        if thirdNum is None:
            for index, item in enumerate(self.full_data):
                if index % firstNum != secondNum:
                    self.full_data[index] = 0
                self.modelSum += self.full_data[index]
        elif thirdNum is not None and firstNum == 13: # 大小
            for index, item in enumerate(self.full_data):
                if index > int(firstNum) and secondNum ==0 : # 小
                    self.full_data[index] = 0 # 大 置为 0
                elif index <= int(firstNum) and secondNum ==1: # 大
                    self.full_data[index] = 0 # 小 置为 0
                self.modelSum += self.full_data[index]
        elif thirdNum is not None and firstNum ==14: # 大小尾数
            for index, item in enumerate(self.full_data):
                if secondNum == 0 and index % 10 <=4: # 大尾
                    self.full_data[index] = 0 # 小尾置为0
                elif secondNum ==1 and index % 10 >=5: # 小尾
                    self.full_data[index] = 0 # 大尾置为0
                self.modelSum += self.full_data[index]

    def getListData(self,temp_list,modelSum):
        print(f"=========={temp_list} 模式和 {modelSum}")
        firstList = []
        index = 0
        for firstItem in temp_list:
            secondList = []
            firstList.append(secondList)
            for secondItem in firstItem:
                # 获取倍数

                Multiple = int(secondItem / modelSum)
                cpArr = self.copyList(self.full_data)
                for arrIndex in range(len(cpArr)):
                    # 计算下注金额
                    cpArr[arrIndex] = int(cpArr[arrIndex] * Multiple)
                secondList.append(', '.join(map(str, cpArr)))
                index = index + 1
        # print(firstList)

        return firstList

    def copyList(self,sourceList):
        targetList = []
        for i in sourceList:
            targetList.append(i)

        return targetList

if __name__ == '__main__':
    pass